package com.amtf.datafile3.cfg.xsv;

import com.amtf.datafile3.cfg.std.StdDataTableDefinition;
import com.amtf.datafile3.core.xsv.parser.XsvDataRecordParser;
import com.amtf.datafile3.core.xsv.render.XsvDataRecordRender;

public class XsvDataTableDefinition extends StdDataTableDefinition {
	private String charset = "UTF-8";
	private int startRow = 1;
	private boolean firstRowTitle = false;
	// private char delimiter = ',';
	// private char quote = ' ';
	// private String rowTerminator = "\r\n";

	public XsvDataTableDefinition(String name, String charset, char delimiter, char quote, int startRow, boolean firstRowTitle) {
		super(name, new XsvDataRecordParser(delimiter, quote), new XsvDataRecordRender(delimiter));
		this.charset = charset;
		// this.delimiter = delimiter;
		// this.quote = quote;
		this.startRow = startRow;
		this.firstRowTitle = firstRowTitle;
	}

	@Override
	public XsvDataTableDefinition clone() {
		XsvDataTableDefinition cloneDef = new XsvDataTableDefinition(name, charset, ',', '"', startRow, firstRowTitle);
		copyTo(cloneDef);
		return cloneDef;
	}

	public String getCharset() {
		return charset;
	}

	public void setCharset(String charset) {
		this.charset = charset;
	}

	public char getDelimiter() {
		return ((XsvDataRecordParser) parser).getDelimiter();
	}

	public void setDelimiter(char delimiter) {
		((XsvDataRecordParser) parser).setDelimiter(delimiter);
		((XsvDataRecordRender) render).setDelimiter(delimiter);
	}

	public char getQuote() {
		return ((XsvDataRecordParser) parser).getQuote();
	}

	public void setQuote(char quote) {
		((XsvDataRecordParser) parser).setQuote(quote);
	}

	public int getStartRow() {
		return startRow;
	}

	public void setStartRow(int startRow) {
		this.startRow = startRow;
	}

	public boolean isFirstRowTitle() {
		return firstRowTitle;
	}

	public void setFirstRowTitle(boolean firstRowTitle) {
		this.firstRowTitle = firstRowTitle;
	}

}
